from pythonds.bltree import *
from pythonds.trees import *


def test():
    print("测试列表实现 ----------------------------------------")
    ltree = btree("1")
    insert_left(ltree, "2")
    insert_right(ltree, "3")
    insert_left(get_left_child(ltree), "4")
    insert_right(get_left_child(ltree), "5")
    insert_right(ltree, "6")
    # print(ltree)
    # print("前序")
    # preorder(ltree)
    # print("中序")
    # inorder(ltree)
    # print("后序")
    # postorder(ltree)
    print("按层")
    layer_order(ltree)
    print("层数", layer_count(ltree))
    print("测试链表实现 ----------------------------------------")
    ctree = BTree("1")
    ctree.insert_left("2")
    ctree.insert_right("3")
    ctree.get_left_child().insert_left("4")
    ctree.get_left_child().insert_right("5")
    ctree.insert_right("6")
    # print("前序")
    # ctree.preorder()
    # print("中序")
    # ctree.inorder()
    # print("后序")
    # ctree.postorder()
    print("按层")
    ctree.layer_order()
    print("层数", ctree.layer_count())
